/*
 * SeeqPodGUI.java
 *
 * Created on March 3, 2008, 8:45 PM
 */

package seeqpod;

import java.io.File;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
/**
 *
 * @author  Rahul
 */
public class SeeqPodGUI_1 extends javax.swing.JFrame implements Runnable{
    
    /** Creates new form SeeqPodGUI */
    public SeeqPodGUI_1() {
        initComponents();
    }
    String[] titles = new String[10];
    SeeqPodTrack[] tracks;
    File dir = null;
    SearchHistory sh = new SearchHistory();

    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Visible = new javax.swing.JLayeredPane();
        nextpage = new javax.swing.JButton();
        checkbox1 = new javax.swing.JCheckBox();
        checkbox2 = new javax.swing.JCheckBox();
        checkbox3 = new javax.swing.JCheckBox();
        checkbox4 = new javax.swing.JCheckBox();
        checkbox5 = new javax.swing.JCheckBox();
        checkbox6 = new javax.swing.JCheckBox();
        checkbox7 = new javax.swing.JCheckBox();
        checkbox8 = new javax.swing.JCheckBox();
        checkbox9 = new javax.swing.JCheckBox();
        checkbox10 = new javax.swing.JCheckBox();
        prevpage = new javax.swing.JButton();
        pagenumber = new javax.swing.JLabel();
        SearchTextField = new javax.swing.JTextField();
        SearchButton = new javax.swing.JButton();
        Download = new javax.swing.JButton();
        TitleLabel = new javax.swing.JLabel();
        SelectedTitle = new javax.swing.JTextField();
        AlbumLabel = new javax.swing.JLabel();
        SelectedAlbum = new javax.swing.JTextField();
        CreatorLabel = new javax.swing.JLabel();
        SelectedCreator = new javax.swing.JTextField();
        GenreLabel = new javax.swing.JLabel();
        SelectedGenre = new javax.swing.JTextField();
        LocationLabel = new javax.swing.JLabel();
        SelectedLocation = new javax.swing.JTextArea();
        Result1 = new javax.swing.JTextField();
        searchresults = new javax.swing.JList();
        Background = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("shmolderin seeqpod V.1 beta");
        setIconImage(new ImageIcon(getClass().getResource("/seeqpod/images/seeqpodlogo.png")).getImage());
        setLocationByPlatform(true);
        setMaximizedBounds(new java.awt.Rectangle(0, 0, 504, 360));
        setMinimumSize(new java.awt.Dimension(504, 360));
        setName("Shmolderin seeqpod"); // NOI18N
        setResizable(false);

        Visible.setAlignmentX(0.0F);
        Visible.setAlignmentY(0.0F);
        Visible.setMaximumSize(new java.awt.Dimension(504, 360));
        Visible.setMinimumSize(new java.awt.Dimension(504, 360));

        nextpage.setBorderPainted(false);
        nextpage.setContentAreaFilled(false);
        nextpage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextpageActionPerformed(evt);
            }
        });
        nextpage.setBounds(441, 313, 40, 32);
        Visible.add(nextpage, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox1.setToolTipText("Check to Add to Que");
        checkbox1.setContentAreaFilled(false);
        checkbox1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox1.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox1.setEnabled(false);
        checkbox1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox1.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox1.setBounds(32, 105, -1, -1);
        Visible.add(checkbox1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox2.setToolTipText("Check to Add to Que");
        checkbox2.setContentAreaFilled(false);
        checkbox2.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox2.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox2.setEnabled(false);
        checkbox2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox2.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox2.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox2.setBounds(32, 125, -1, -1);
        Visible.add(checkbox2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox3.setToolTipText("Check to Add to Que");
        checkbox3.setContentAreaFilled(false);
        checkbox3.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox3.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox3.setEnabled(false);
        checkbox3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox3.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox3.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox3.setBounds(32, 145, -1, -1);
        Visible.add(checkbox3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox4.setToolTipText("Check to Add to Que");
        checkbox4.setContentAreaFilled(false);
        checkbox4.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox4.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox4.setEnabled(false);
        checkbox4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox4.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox4.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox4.setBounds(32, 165, -1, -1);
        Visible.add(checkbox4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox5.setToolTipText("Check to Add to Que");
        checkbox5.setContentAreaFilled(false);
        checkbox5.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox5.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox5.setEnabled(false);
        checkbox5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox5.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox5.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox5.setBounds(32, 185, -1, -1);
        Visible.add(checkbox5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox6.setToolTipText("Check to Add to Que");
        checkbox6.setContentAreaFilled(false);
        checkbox6.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox6.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox6.setEnabled(false);
        checkbox6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox6.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox6.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox6.setBounds(32, 205, -1, -1);
        Visible.add(checkbox6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox7.setToolTipText("Check to Add to Que");
        checkbox7.setContentAreaFilled(false);
        checkbox7.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox7.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox7.setEnabled(false);
        checkbox7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox7.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox7.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox7.setBounds(32, 225, -1, -1);
        Visible.add(checkbox7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox8.setToolTipText("Check to Add to Que");
        checkbox8.setContentAreaFilled(false);
        checkbox8.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox8.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox8.setEnabled(false);
        checkbox8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox8.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox8.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox8.setBounds(32, 245, -1, -1);
        Visible.add(checkbox8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox9.setToolTipText("Check to Add to Que");
        checkbox9.setContentAreaFilled(false);
        checkbox9.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox9.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox9.setEnabled(false);
        checkbox9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox9.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox9.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox9.setBounds(32, 265, -1, -1);
        Visible.add(checkbox9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox10.setToolTipText("Check to Add to Que");
        checkbox10.setContentAreaFilled(false);
        checkbox10.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox10.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox10.setEnabled(false);
        checkbox10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox10.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox10.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox10.setBounds(32, 285, -1, -1);
        Visible.add(checkbox10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        prevpage.setBorder(null);
        prevpage.setContentAreaFilled(false);
        prevpage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prevpageActionPerformed(evt);
            }
        });
        prevpage.setBounds(26, 313, 40, 30);
        Visible.add(prevpage, javax.swing.JLayeredPane.DEFAULT_LAYER);

        pagenumber.setFont(new java.awt.Font("Cambria", 1, 14));
        pagenumber.setForeground(new java.awt.Color(255, 255, 255));
        pagenumber.setBounds(148, 73, 20, 20);
        Visible.add(pagenumber, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SearchTextField.setFont(new java.awt.Font("Cambria", 1, 24));
        SearchTextField.setForeground(new java.awt.Color(40, 111, 176));
        SearchTextField.setText("Search");
        SearchTextField.setToolTipText("Scroll with your mouse to go through history.");
        SearchTextField.setAlignmentX(0.0F);
        SearchTextField.setAlignmentY(0.0F);
        SearchTextField.setBorder(null);
        SearchTextField.setName("Search Bar"); // NOI18N
        SearchTextField.setOpaque(false);
        SearchTextField.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
            public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
                SearchTextFieldMouseWheelMoved(evt);
            }
        });
        SearchTextField.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SearchTextFieldMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                SearchTextFieldMouseEntered(evt);
            }
        });
        SearchTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                SearchTextFieldKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                SearchTextFieldKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                SearchTextFieldKeyTyped(evt);
            }
        });
        SearchTextField.setBounds(87, 29, 302, 38);
        Visible.add(SearchTextField, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SearchButton.setFont(new java.awt.Font("Cordia New", 1, 36));
        SearchButton.setForeground(new java.awt.Color(255, 255, 255));
        SearchButton.setAlignmentY(0.0F);
        SearchButton.setBorder(null);
        SearchButton.setContentAreaFilled(false);
        SearchButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        SearchButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        SearchButton.setMaximumSize(new java.awt.Dimension(120, 23));
        SearchButton.setMinimumSize(new java.awt.Dimension(120, 23));
        SearchButton.setPreferredSize(new java.awt.Dimension(101, 23));
        SearchButton.setRequestFocusEnabled(false);
        SearchButton.setVerifyInputWhenFocusTarget(false);
        SearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchButtonActionPerformed(evt);
            }
        });
        SearchButton.setBounds(389, 29, 93, 40);
        Visible.add(SearchButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Download.setAlignmentY(0.0F);
        Download.setBorder(null);
        Download.setContentAreaFilled(false);
        Download.setRequestFocusEnabled(false);
        Download.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                DownloadMouseClicked(evt);
            }
        });
        Download.setBounds(66, 313, 373, 32);
        Visible.add(Download, javax.swing.JLayeredPane.DEFAULT_LAYER);

        TitleLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        TitleLabel.setForeground(new java.awt.Color(255, 255, 255));
        TitleLabel.setText("Title:");
        TitleLabel.setEnabled(false);
        TitleLabel.setBounds(347, 108, 39, 20);
        Visible.add(TitleLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SelectedTitle.setEditable(false);
        SelectedTitle.setFont(new java.awt.Font("Cambria", 1, 12));
        SelectedTitle.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        SelectedTitle.setAutoscrolls(false);
        SelectedTitle.setBorder(null);
        SelectedTitle.setOpaque(false);
        SelectedTitle.setRequestFocusEnabled(false);
        SelectedTitle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectedTitleActionPerformed(evt);
            }
        });
        SelectedTitle.setBounds(345, 129, 130, 20);
        Visible.add(SelectedTitle, javax.swing.JLayeredPane.DEFAULT_LAYER);

        AlbumLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        AlbumLabel.setForeground(new java.awt.Color(255, 255, 255));
        AlbumLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        AlbumLabel.setText("Album:");
        AlbumLabel.setEnabled(false);
        AlbumLabel.setBounds(347, 188, 50, 14);
        Visible.add(AlbumLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SelectedAlbum.setEditable(false);
        SelectedAlbum.setFont(new java.awt.Font("Tahoma", 1, 11));
        SelectedAlbum.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        SelectedAlbum.setBorder(null);
        SelectedAlbum.setOpaque(false);
        SelectedAlbum.setBounds(345, 205, 130, 20);
        Visible.add(SelectedAlbum, javax.swing.JLayeredPane.DEFAULT_LAYER);

        CreatorLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        CreatorLabel.setForeground(new java.awt.Color(255, 255, 255));
        CreatorLabel.setText("Artist:");
        CreatorLabel.setEnabled(false);
        CreatorLabel.setBounds(348, 150, 50, 14);
        Visible.add(CreatorLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SelectedCreator.setEditable(false);
        SelectedCreator.setFont(new java.awt.Font("Cambria", 1, 12));
        SelectedCreator.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        SelectedCreator.setBorder(null);
        SelectedCreator.setOpaque(false);
        SelectedCreator.setBounds(345, 170, 130, -1);
        Visible.add(SelectedCreator, javax.swing.JLayeredPane.DEFAULT_LAYER);

        GenreLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        GenreLabel.setForeground(new java.awt.Color(255, 255, 255));
        GenreLabel.setText("Genre:");
        GenreLabel.setEnabled(false);
        GenreLabel.setBounds(347, 226, 50, -1);
        Visible.add(GenreLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SelectedGenre.setEditable(false);
        SelectedGenre.setFont(new java.awt.Font("Tahoma", 1, 11));
        SelectedGenre.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        SelectedGenre.setBorder(null);
        SelectedGenre.setOpaque(false);
        SelectedGenre.setBounds(345, 247, 130, -1);
        Visible.add(SelectedGenre, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LocationLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        LocationLabel.setForeground(new java.awt.Color(255, 255, 255));
        LocationLabel.setText("Location:");
        LocationLabel.setEnabled(false);
        LocationLabel.setBounds(347, 265, 70, 15);
        Visible.add(LocationLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SelectedLocation.setColumns(20);
        SelectedLocation.setEditable(false);
        SelectedLocation.setFont(new java.awt.Font("Cambria", 0, 8));
        SelectedLocation.setLineWrap(true);
        SelectedLocation.setRows(5);
        SelectedLocation.setOpaque(false);
        SelectedLocation.setBounds(345, 283, 130, 20);
        Visible.add(SelectedLocation, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Result1.setEditable(false);
        Result1.setFont(new java.awt.Font("Cambria", 1, 14));
        Result1.setForeground(new java.awt.Color(150, 194, 31));
        Result1.setBorder(null);
        Result1.setOpaque(false);
        Result1.setBounds(56, 101, 275, 28);
        Visible.add(Result1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        searchresults.setFont(new java.awt.Font("Cambria", 1, 14));
        searchresults.setForeground(new java.awt.Color(150, 194, 31));
        searchresults.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        searchresults.setAlignmentX(0.0F);
        searchresults.setAlignmentY(0.0F);
        searchresults.setOpaque(false);
        searchresults.setSelectionBackground(new java.awt.Color(102, 153, 255));
        searchresults.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                searchresultsMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                searchresultsMouseEntered(evt);
            }
        });
        searchresults.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                searchresultsValueChanged(evt);
            }
        });
        searchresults.setBounds(56, 106, 20, 200);
        Visible.add(searchresults, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Background.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/seeqpod2.png"))); // NOI18N
        Background.setAlignmentY(0.0F);
        Background.setBounds(0, 0, 504, 360);
        Visible.add(Background, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jScrollPane1.setBounds(80, 110, -1, -1);
        Visible.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(Visible, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 504, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(Visible, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 360, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    String search;
    private void updatecheckboxes(){
        checkboxes[0] = checkbox1;
        checkboxes[1] = checkbox2;
        checkboxes[2] = checkbox3;
        checkboxes[3] = checkbox4;
        checkboxes[4] = checkbox5;
        checkboxes[5] = checkbox6;
        checkboxes[6] = checkbox7;
        checkboxes[7] = checkbox8;
        checkboxes[8] = checkbox9;
        checkboxes[9] = checkbox10;
    }
    private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchButtonActionPerformed
        // TODO add your handling code here:
        SeeqPod sp = new SeeqPod();
        pagenumber.setText("1");
        int numofresults = 10;
        search = SearchTextField.getText();
        tracks = sp.search(search, 0, numofresults);
        sh.add(search);
        numofresults = tracks.length;
        titles = new String[numofresults];
        
        for(int i =0; i<numofresults; i++)
            titles[i] = tracks[i].getTitle();
        if(!searchresults.isEnabled()){
            searchresults.setEnabled(true);
            searchresults.setModel(new javax.swing.AbstractListModel() {
            public int getSize() { return titles.length; }
            public Object getElementAt(int i) { return titles[i]; }
        });
        
        }else if(searchresults.isEnabled()){
            searchresults.setEnabled(false);
            searchresults.setEnabled(true);
            searchresults.setModel(new javax.swing.AbstractListModel() {
            public int getSize() { return titles.length; }
            public Object getElementAt(int i) { return titles[i]; }
        });
        
        }
        
}//GEN-LAST:event_SearchButtonActionPerformed

    private void searchresultsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_searchresultsMouseClicked

    }//GEN-LAST:event_searchresultsMouseClicked
    private String path = null;
    Threading_1 t = new Threading_1();
    private void DownloadMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DownloadMouseClicked
        try{
        updatecheckboxes();
        boolean[] selected = new boolean[10];

        for(int i = 0; i < 10; i++){
            selected[i] = checkboxes[i].isSelected();
            if(selected[i]){
                String link = tracks[i].getLocation();
                String filename = link.substring(link.lastIndexOf("/") + 1).replaceAll("%20", " ");
                SeeqPodGUI_1 spg = new SeeqPodGUI_1();
                if(path == null)
                    path = spg.chooseFile().getPath() + "/";
                File f = new File(path + filename);

                Download d = new Download();
                d.setfile(f);
                d.seturl(link);
                d.start();
            }
        }
        updatecheckboxes();
        }catch(ArrayIndexOutOfBoundsException e){
         
        }
    }//GEN-LAST:event_DownloadMouseClicked
    public File chooseFile(){
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(1);
        fc.setDialogTitle("Choose Directory to Save MP3");
        int result = fc.showSaveDialog(null);
        if(result == JFileChooser.APPROVE_OPTION)
            dir = fc.getSelectedFile();
        return dir;
    }
    ArrayList<SeeqPodTrack[]> trackhistory = new ArrayList<SeeqPodTrack[]>();
    private void SearchTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SearchTextFieldKeyPressed

    }//GEN-LAST:event_SearchTextFieldKeyPressed
    public void search(){
        trackhistory.clear();
        
        updatecheckboxes();
        for(int i = 0; i < 10; i++){
            checkboxes[i].setSelected(false);
            checkboxes[i].setEnabled(false);
        }
        search = SearchTextField.getText();
                pagenumber.setText("1");
        SeeqPod sp = new SeeqPod();
        int numofresults = 10;
        tracks = sp.search(search, 0, numofresults);
        if(tracks == null){

            pagenumber.setText("" + (page + 1));

            numofresults = tracks.length;
            titles = new String[numofresults];

            for(int i =0; i<numofresults; i++){
                checkboxes[i].setEnabled(true);
                titles[i] = tracks[i].getTitle();
            }
            if(numofresults == 0){
                titles = new String[1];
                titles[0] = "No Results Found";
            }
            if(!searchresults.isEnabled()){
                searchresults.setEnabled(true);
                searchresults.setModel(new javax.swing.AbstractListModel() {
                public int getSize() { return titles.length; }
                public Object getElementAt(int i) { return titles[i]; }
            });

            }
            if(searchresults.isEnabled()){
                searchresults.setEnabled(false);
                searchresults.setEnabled(true);
                searchresults.setModel(new javax.swing.AbstractListModel() {
                public int getSize() { return titles.length; }
                public Object getElementAt(int i) { return titles[i]; }
            });
            }
        }
    }
    private void SelectedTitleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectedTitleActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_SelectedTitleActionPerformed

    private void SearchTextFieldMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SearchTextFieldMouseEntered
       
    }//GEN-LAST:event_SearchTextFieldMouseEntered

    private void searchresultsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_searchresultsValueChanged
        try{
        SelectedTitle.setText(tracks[searchresults.getSelectedIndex()].getTitle());
        SelectedAlbum.setText(tracks[searchresults.getSelectedIndex()].getAlbum());
        SelectedCreator.setText(tracks[searchresults.getSelectedIndex()].getCreator());
        SelectedGenre.setText(tracks[searchresults.getSelectedIndex()].getGenre());
        SelectedLocation.setText((tracks[searchresults.getSelectedIndex()].getLocation()).replaceAll("%20", " "));
        /*      
        AlbumLabel.setEnabled(true);//GEN-LAST:event_searchresultsValueChanged
        */
        AlbumLabel.setEnabled(true);
        CreatorLabel.setEnabled(true);
        GenreLabel.setEnabled(true);
        TitleLabel.setEnabled(true);
        LocationLabel.setEnabled(true);

        }catch(ArrayIndexOutOfBoundsException e){
            
        }
    }                                          

    private int count = 0;
    private void SearchTextFieldMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_SearchTextFieldMouseWheelMoved
        try{
        SearchTextField.setText(sh.get(count));
        count++;
        }catch(IndexOutOfBoundsException e){
            count = 0;
        }
        
    }//GEN-LAST:event_SearchTextFieldMouseWheelMoved
 
    private void SearchTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SearchTextFieldKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_SearchTextFieldKeyTyped
    int page = 0;
    private void nextpageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextpageActionPerformed
        trackhistory.add(tracks);
        updatecheckboxes();
        for(int i = 0; i < 10; i++){
            checkboxes[i].setSelected(false);
            checkboxes[i].setEnabled(false);
        }
        page++;
        SeeqPod sp = new SeeqPod();
        int numofresults = 10;
        tracks = sp.search(search, 10* page, numofresults);
        pagenumber.setText("" + (page + 1));

        numofresults = tracks.length;
        titles = new String[numofresults];
        
        for(int i =0; i<numofresults; i++){
            checkboxes[i].setEnabled(true);
            titles[i] = tracks[i].getTitle();
        }
        if(!searchresults.isEnabled()){
            searchresults.setEnabled(true);
            searchresults.setModel(new javax.swing.AbstractListModel() {
            public int getSize() { return titles.length; }
            public Object getElementAt(int i) { return titles[i]; }
        });
        
        }else if(searchresults.isEnabled()){
            searchresults.setEnabled(false);
            searchresults.setEnabled(true);
            searchresults.setModel(new javax.swing.AbstractListModel() {
            public int getSize() { return titles.length; }
            public Object getElementAt(int i) { return titles[i]; }
        });
        }
    }//GEN-LAST:event_nextpageActionPerformed

    private void prevpageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevpageActionPerformed
        if(page >= 1){
            updatecheckboxes();
            for(int i =0; i <10; i++)
                checkboxes[i].setEnabled(false);
            SeeqPod sp = new SeeqPod();
            int numofresults = 10;
            pagenumber.setText("" + page);
            page--;

            tracks = trackhistory.get(page);

            for(int i =0; i<numofresults; i++){
                checkboxes[i].setEnabled(true);
                titles[i] = tracks[i].getTitle();
            }
            
            if(!searchresults.isEnabled()){
                searchresults.setEnabled(true);
                searchresults.setModel(new javax.swing.AbstractListModel() {
                public int getSize() { return titles.length; }
                public Object getElementAt(int i) { return titles[i]; }
            });

            }else if(searchresults.isEnabled()){
                searchresults.setEnabled(false);
                searchresults.setEnabled(true);
                searchresults.setModel(new javax.swing.AbstractListModel() {
                public int getSize() { return titles.length; }
                public Object getElementAt(int i) { return titles[i]; }
            });

            }

        }

    }//GEN-LAST:event_prevpageActionPerformed

    Thread search1;
    private void SearchTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SearchTextFieldKeyReleased
      if(search1 != null){
          try{
              if(search1.isAlive())
                      search1.interrupt();  
              }catch(Exception e){
                  e.printStackTrace();
          }
      }
      search1 = new Thread(this);
      search1.start();
    }//GEN-LAST:event_SearchTextFieldKeyReleased

    private void SearchTextFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SearchTextFieldMouseClicked
        SearchTextField.setText("");
    }//GEN-LAST:event_SearchTextFieldMouseClicked

    private void searchresultsMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_searchresultsMouseEntered

        search = SearchTextField.getText();
        if(!sh.search(search))
            sh.add(search);
    }//GEN-LAST:event_searchresultsMouseEntered


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                   try {
	    // Set System L&F
        UIManager.setLookAndFeel(
            UIManager.getSystemLookAndFeelClassName());
            } 
            catch (UnsupportedLookAndFeelException e) {
               // handle exception
            }
            catch (ClassNotFoundException e) {
               // handle exception
            }
            catch (InstantiationException e) {
               // handle exception
            }
            catch (IllegalAccessException e) {
               // handle exception
            }
                new SeeqPodGUI_1().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel AlbumLabel;
    private javax.swing.JLabel Background;
    private javax.swing.JLabel CreatorLabel;
    private javax.swing.JButton Download;
    private javax.swing.JLabel GenreLabel;
    private javax.swing.JLabel LocationLabel;
    private javax.swing.JTextField Result1;
    private javax.swing.JButton SearchButton;
    private javax.swing.JTextField SearchTextField;
    private javax.swing.JTextField SelectedAlbum;
    private javax.swing.JTextField SelectedCreator;
    private javax.swing.JTextField SelectedGenre;
    private javax.swing.JTextArea SelectedLocation;
    private javax.swing.JTextField SelectedTitle;
    private javax.swing.JLabel TitleLabel;
    private javax.swing.JLayeredPane Visible;
    private javax.swing.JCheckBox checkbox1;
    private javax.swing.JCheckBox checkbox10;
    private javax.swing.JCheckBox checkbox2;
    private javax.swing.JCheckBox checkbox3;
    private javax.swing.JCheckBox checkbox4;
    private javax.swing.JCheckBox checkbox5;
    private javax.swing.JCheckBox checkbox6;
    private javax.swing.JCheckBox checkbox7;
    private javax.swing.JCheckBox checkbox8;
    private javax.swing.JCheckBox checkbox9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton nextpage;
    private javax.swing.JLabel pagenumber;
    private javax.swing.JButton prevpage;
    private javax.swing.JList searchresults;
    // End of variables declaration//GEN-END:variables
    JCheckBox checkboxes[] = {
        checkbox1,
        checkbox2,
        checkbox3,
        checkbox4,
        checkbox5,
        checkbox6,
        checkbox7,
        checkbox8,
        checkbox9,
        checkbox10
    };

    public void run() {
        trackhistory.clear();
        
        updatecheckboxes();
        for(int i = 0; i < 10; i++){
            checkboxes[i].setSelected(false);
            checkboxes[i].setEnabled(false);
        }
        search = SearchTextField.getText();
                pagenumber.setText("1");
        int numofresults = 10;
            try {
                SearchSeeqResultsThread ssrt = new SearchSeeqResultsThread(search, SeeqPod.KEY, 0, numofresults);
                ssrt.start();
                ssrt.join();
                tracks = ssrt.getTracks();
            } catch (InterruptedException ex) {}
        
        if(tracks == null){

            pagenumber.setText("" + (page + 1));

            numofresults = tracks.length;
            titles = new String[numofresults];

            for(int i =0; i<numofresults; i++){
                checkboxes[i].setEnabled(true);
                titles[i] = tracks[i].getTitle();
            }
            if(numofresults == 0){
                titles = new String[1];
                titles[0] = "No Results Found";
            }
            if(!searchresults.isEnabled()){
                searchresults.setEnabled(true);
                searchresults.setModel(new javax.swing.AbstractListModel() {
                public int getSize() { return titles.length; }
                public Object getElementAt(int i) { return titles[i]; }
            });

            }
            if(searchresults.isEnabled()){
                searchresults.setEnabled(false);
                searchresults.setEnabled(true);
                searchresults.setModel(new javax.swing.AbstractListModel() {
                public int getSize() { return titles.length; }
                public Object getElementAt(int i) { return titles[i]; }
            });
            }
        }
    }
}
